package it.polimi.traveldream.managers;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConnectionManagerImpl {

	private static final String URL = "jdbc:mysql://localhost:3306/";
	private static final String DBName = "travel_dream_db";
	private static final String User = "TravelDream";
	private static final String Password = "traveldream";
	private static final String DriverName = "com.mysql.jdbc.Driver";

	public static Connection getConnection() {
		try {
			Class.forName(DriverName);
		} catch (ClassNotFoundException e) {
			System.err.println("Error during the loading of the driver " + DriverName);
			throw new RuntimeException(e);
		}

		try {
			Connection connection = DriverManager.getConnection(URL + DBName, User, Password);
			return connection;
		} catch (SQLException e) {
			System.err.println("Error during the creation of the connection to " + URL + DBName);
			throw new RuntimeException(e);
		}
	}
}
